unit UPesquisaFonteRecurso;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFormPesquisa, StdCtrls, DB, DBTables, Grids, DBGrids, Buttons,
  ExtCtrls;

type
  TFPesquisaFonteRecurso = class(TFormPesquisa)
    Label1: TLabel;
    edDescricao: TEdit;
    procedure BtnConsultarClick(Sender: TObject);
    procedure BtnSelecionarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPesquisaFonteRecurso: TFPesquisaFonteRecurso;

implementation

uses CadastroFonteRecurso;

{$R *.dfm}

procedure TFPesquisaFonteRecurso.BtnConsultarClick(Sender: TObject);
const
  ctPesquisa =
    'SELECT * FROM FONTERECURSO WHERE FONT_DESCRICAO LIKE ''%s''';
begin
  QPesquisa.Close;
  QPesquisa.SQL.Clear;
  QPesquisa.SQL.Add(Format(ctPesquisa,[edDescricao.Text + '%']));
  QPesquisa.Open;

  inherited;

end;

procedure TFPesquisaFonteRecurso.BtnSelecionarClick(Sender: TObject);
begin
  inherited;
  with FCadastroFonteRecurso do
  begin
    if QCadastro.State = dsBrowse then
      QCadastro.Locate('FONT_CODIGO',QPesquisa.FieldByName('FONT_CODIGO').AsVariant,[]);
  end;
  Close;
end;

end.
